package com.example.wxy.bbtapp.Receivers;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.example.wxy.bbtapp.Common.ServiceHelper;
import com.example.wxy.bbtapp.Service.BBTService;
import com.example.wxy.bbtapp.Startup.AppSettings;

/**
 * Created by yons on 2017/9/16.
 */

public class LockScreenReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())) {
            if(!ServiceHelper.isServiceRunning(context, "BBTServices"))
            {
                try
                {
                    // 开启服务
                    context.startService(new Intent(context, BBTService.class));
                }
                catch (Exception E)
                {
                    Log.v(AppSettings.DebugTag, "startService Error:" + E.getMessage());
                }
            }


        }
    }
}
